<!DOCTYPE html>
<html lang="en">
<script src="js/jquery-3.4.1.min.js"></script>
<script>
    $(function () {
        //给提交按钮添加点击事件
        $("#sub").click(function () {
            //收集一类卡信息(绑卡界面输入的信息),中途带上二类卡的uuid,传到数据库accountone表,实现两卡绑定
            var name = $("input[name='name']").val();
            var card_num = $("input[name='card_num']").val();
            var phone = $("input[name='phone']").val();
            var payPassword = $("input[name='payPassword']").val();

            if (!name){
                alert("姓名必填！");
                $("input[name = 'name']").focus();
                return;
            }
            if (!card_num){
                alert("一类卡卡号必填！");
                $("input[name='card_num']").focus();
                return;
            }
            if (!phone){
                alert("一类卡预留手机号必填");
                $("input[name='phone']").focus();
                return;
            }
            if (!payPassword){
                alert("一类卡支付密码必填！")
                $("input[name='payPassword']").focus();
                return;
            }
            //前后端值传递
            $.post("subscriptioncard.servlet",{"name":name,"card_num":card_num,"phone":phone,"payPassword":payPassword},function (data) {

                if (data == 'y'){
                    alert("绑卡成功");
                    //跳转到首页
                    window.location.href="account_index.jsp";
                }else{
                    alert("绑卡失败");
                    //跳转到当前页,重新开户
                    window.location.href="subscriptioncard.html";
                }
            });
        });
    });
</script>
<head>
    <meta charset="UTF-8">
    <title>绑卡</title>
</head>
<body>
    <form>
        <table  width="60%" align="center" border="1">
            <tr>
                <td align="center"><h1>绑卡</h1></td>
            </tr>
            <tr align="center">
                <td><h3>请输入您的姓名：&nbsp;&nbsp;&nbsp;&nbsp;<input type="text"  name="name" id="name" style="width:300px;height:30px;font-size: large" /></h3></td>
            </tr>
            <tr align="center">
                <td><h3>请输入银行卡号：&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="card_num" id="card_num" style="width: 300px;height: 30px;font-size: large" /></h3></td>
            </tr>
            <tr align="center">
                <td><h4>请输入银行卡预留手机号：<input type="text" name="phone" id="phone" style="width: 300px;height: 30px;font-size: large" /></h4></td>
            </tr>
            <tr align="center">
                <td><h3>请输入支付密码：&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="payPassword" id="payPassword" style="width: 300px;height: 30px;font-size: large" /></h3></td>
            </tr>
            <tr align="center">
                <td><h3><input type="button" value="绑定" id="sub" style="width: 350px;height: 60px;font-size: large;color: blue" /></h3></td>
            </tr>
            <tr align="center">
                <td><h3><input type="reset" value="清空" id="res" style="width: 350px;height: 60px;font-size: larger;color: brown" /></h3></td>
            </tr>
        </table>
    </form>
</body>
</html>